﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ManageArticle.ascx.cs"
    Inherits="NLLSite.Administrator.UserControl.ArticleManager" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<script runat="server" language="C#">

    // We are not using a code behind page here just for simplicity in the
    // sample file. In this way we don't have to distribute a compiled DLL for
    // this page. In real cases, the following code will instead be defined in
    // a code behind file.

    protected override void OnLoad(EventArgs e)
    {
        CKFinder.FileBrowser _FileBrowser = new CKFinder.FileBrowser();
        _FileBrowser.BasePath = "../../ckfinder/";
        _FileBrowser.SetupCKEditor(CKEditor1);
    }

</script>
<script type="text/javascript" src="../../ckfinder/ckfinder.js"></script>
<script type="text/javascript">

    function BrowseServer() {
        // You can use the "CKFinder" class to render CKFinder in a page:
        var finder = new CKFinder();
        finder.basePath = '../../ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
        finder.selectActionFunction = SetFileField;
        finder.popup();

        // It can also be done in a single line, calling the "static"
        // popup( basePath, width, height, selectFunction ) function:
        // CKFinder.popup( '../', null, null, SetFileField ) ;
        //
        // The "popup" function can also accept an object as the only argument.
        // CKFinder.popup( { basePath : '../', selectActionFunction : SetFileField } ) ;
    }

    // This is a sample function which is called when a file is selected in CKFinder.
    function SetFileField(fileUrl) {
        document.getElementById('ManageArticle1_TxtImage').value = fileUrl;
        //Element ID = Ten class usercontrol + 1 + ID cua text box.
    }

</script>
<div class="box box-100">
    <div class="boxin">
        <div class="header">
            <h3>
                Quản lý bài viết</h3>
        </div>
        <div style="padding: 18px;">
            <!--<form class="basic" action="" method="post" enctype="multipart/form-data"><!-- Default basic forms -->
            <div class="inner-form">
                <table>
                    <tr>
                        <td>
                            <asp:Panel ID="Panel1" runat="server" Visible="False">
                                <table style="width: 100%;">
                                    <tr>
                                        <td>
                                            Tên Tiêu Đề :
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtTitle" runat="server" Width="400px"></asp:TextBox>
                                        </td>
                                        <td>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtTitle"
                                                ErrorMessage="*"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Image Upload :
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtImage" runat="server" Width="300px"></asp:TextBox>
                                            <input type="button" value="Browse" onclick="BrowseServer();" style="width: 96px" class="altbutton" />
                                        </td>
                                        <td>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TxtImage"
                                                ErrorMessage="*"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Miêu Tả Bài Viết :
                                        </td>
                                        <td>
                                            <asp:TextBox ID="Txtdes" runat="server" Height="100px" TextMode="MultiLine" Width="400px"></asp:TextBox>
                                        </td>
                                        <td>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Txtdes"
                                                ErrorMessage="*"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Nội dung :
                                        </td>
                                        <td>
                                            <CKEditor:CKEditorControl ID="CKEditor1" runat="server" Width="600px"></CKEditor:CKEditorControl>
                                        </td>
                                        <td>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="CKEditor1"
                                                ErrorMessage="*"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Tác Giả :
                                        </td>
                                        <td>
                                            <asp:ListBox ID="LbxAut" runat="server" DataSourceID="LinqDataSource2" DataTextField="AuthorName"
                                                DataValueField="ID" Width="250px"></asp:ListBox>
                                            <asp:LinqDataSource ID="LinqDataSource2" runat="server" ContextTypeName="DAL_Class.NLLDataContext"
                                                TableName="Authors">
                                            </asp:LinqDataSource>
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Chọn menu:</td>
                                        <td>
                                            <asp:DropDownList ID="Ddlposi" runat="server" AutoPostBack="True" 
                                                onselectedindexchanged="Ddlposi_SelectedIndexChanged" Width="256px">
                                                <asp:ListItem>Top</asp:ListItem>
                                                <asp:ListItem Value="Chủ Đề">Chủ Đề</asp:ListItem>
                                                <asp:ListItem Value="Hội Thảo">Hội Thảo</asp:ListItem>
                                            </asp:DropDownList>
                                            <br />
                                            <asp:ListBox ID="lbxMenu" runat="server" 
                                                DataTextField="Name" DataValueField="ID" Width="250px">
                                            </asp:ListBox>
                                            <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                                                ContextTypeName="DAL_Class.NLLDataContext" TableName="View_Menu_Articles" 
                                                Select="new (ID, Name)" Where="Position == @Position">
                                                <WhereParameters>
                                                    <asp:ControlParameter ControlID="Ddlposi" DefaultValue="Top" Name="Position" 
                                                        PropertyName="SelectedValue" Type="String" />
                                                </WhereParameters>
                                            </asp:LinqDataSource>
                                            <asp:LinqDataSource ID="LinqDataSource5" runat="server" 
                                                ContextTypeName="DAL_Class.NLLDataContext" Select="new (ID, Name)" 
                                                TableName="Menus" Where="Position == @Position">
                                                <WhereParameters>
                                                    <asp:Parameter DefaultValue="Chủ Đề" Name="Position" Type="String" />
                                                </WhereParameters>
                                            </asp:LinqDataSource>
                                            <asp:LinqDataSource ID="LinqDataSource6" runat="server" 
                                                ContextTypeName="DAL_Class.NLLDataContext" Select="new (ID, Name)" 
                                                TableName="Menus">
                                            </asp:LinqDataSource>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            &nbsp;</td>
                                        <td>
                                            &nbsp;</td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Hiển thị trên Trang chủ :
                                        </td>
                                        <td>
                                            <asp:CheckBox ID="CbxFront" runat="server" />
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cho vào Video :
                                            <asp:CheckBox ID="CbxSlide" runat="server" />
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            MetaTitle :
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtMetatit" runat="server" Width="400px"></asp:TextBox>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            MetaDescription :
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtMetades" runat="server" Width="400px"></asp:TextBox>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            MetaKeywords :
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtMetakey" runat="server" Width="400px"></asp:TextBox>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            MetaRobots :
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtMetaro" runat="server" Width="400px"></asp:TextBox>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            MetaAuthor :
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtMetaAut" runat="server" Width="400px"></asp:TextBox>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td>
                                            <asp:Label ID="Lblchk" runat="server" CssClass="style1"></asp:Label>
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td>
                                            <asp:Button ID="BtnAdd" runat="server" Text="Thay Đổi" OnClick="BtnAdd_Click" 
                                                CssClass="altbutton" />
                                            &nbsp;&nbsp;
                                            <asp:Button ID="Button2" runat="server" Text="Thiết Lập Lại" 
                                                OnClick="Button2_Click" CssClass="altbutton" />
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Panel ID="Panel2" runat="server">
                                &nbsp;
                                <asp:CheckBox ID="CbxDele" runat="server" AutoPostBack="True" 
                                    oncheckedchanged="CbxDele_CheckedChanged" />
                                <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Xóa" 
                                    OnClientClick="javascript:return confirm('Bạn có muốn xóa?')" 
                                    CssClass="altbutton" />
                                <asp:Button ID="btnThem" runat="server" 
                                    Text="Thêm mới" PostBackUrl="~/Administrator/ThemBaiViet.aspx" 
                                    CssClass="altbutton" onclick="btnThem_Click" />
                                <br />
                                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                                    DataSourceID="LinqDataSource3" EnableModelValidation="True" GridLines="None"
                                    DataKeyNames="ID" AllowPaging="True" 
                                    OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="920px" 
                                    AllowSorting="True" ForeColor="#333333">
                                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="cbx" runat="server" />
                                            </ItemTemplate>
                                            <HeaderStyle HorizontalAlign="Left" />
                                            <ItemStyle HorizontalAlign="Left" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" InsertVisible="False"
                                            ReadOnly="True" Visible="False" >
                                        <HeaderStyle HorizontalAlign="Left" />
                                        <ItemStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="AuthorName" HeaderText="Tên Tác Giả" 
                                            SortExpression="AuthorName" >
                                        <HeaderStyle HorizontalAlign="Left" />
                                        <ItemStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Name" HeaderText="Menu" SortExpression="Name" >
                                        <HeaderStyle HorizontalAlign="Left" />
                                        <ItemStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Title" HeaderText="Tiêu Đề" SortExpression="Title" >
                                        <HeaderStyle HorizontalAlign="Left" />
                                        <ItemStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="CreateDate" HeaderText="Ngày Tạo" 
                                            SortExpression="CreateDate" >
                                        <HeaderStyle HorizontalAlign="Left" />
                                        <ItemStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:CheckBoxField DataField="IsSilde" HeaderText="Hiển Thị Trên Slide" 
                                            SortExpression="IsSilde" >
                                        <HeaderStyle HorizontalAlign="Left" />
                                        <ItemStyle HorizontalAlign="Left" />
                                        </asp:CheckBoxField>
                                        <asp:CheckBoxField DataField="IsFrontPage" HeaderText="Hiển Thị Trên Trang chủ" 
                                            SortExpression="IsFrontPage" >
                                        <HeaderStyle HorizontalAlign="Left" />
                                        <ItemStyle HorizontalAlign="Left" />
                                        </asp:CheckBoxField>
                                        <asp:BoundField DataField="MetaTitle" HeaderText="Meta Title" 
                                            SortExpression="MetaTitle" >
                                        <HeaderStyle HorizontalAlign="Left" />
                                        <ItemStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:CommandField ShowSelectButton="True" SelectText="Sửa" />
                                        <asp:TemplateField HeaderText="MenuID" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="LblMenuID" runat="server" Text='<%# Eval("MenuID") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="ThumbImage" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="LblThumbi" runat="server" Text='<%# Eval("ThumbImage") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Description" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="Lbldes" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Content" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="Lblconte" runat="server" Text='<%# Eval("Content") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="AuthorID" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="Lblauthor" runat="server" Text='<%# Eval("AuthorID") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Metades" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="LblMedes" runat="server" Text='<%# Eval("MetaDescription") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Metakey" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="LblMekey" runat="server" Text='<%# Eval("MetaKeywords") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Metaro" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="Lblmero" runat="server" Text='<%# Eval("MetaRobots") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="metaaut" Visible="False">
                                            <ItemTemplate>
                                                <asp:Label ID="Lblmetaau" runat="server" Text='<%# Eval("MetaAuthor") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <EditRowStyle BackColor="#999999" />
                                    <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
                                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                </asp:GridView>
                                <asp:LinqDataSource ID="LinqDataSource3" runat="server" ContextTypeName="DAL_Class.NLLDataContext"
                                    TableName="View_Article_ALLs">
                                </asp:LinqDataSource>
                                <br />
                            </asp:Panel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
